package com.fatmeraid.controller.user;

import com.fatmeraid.common.result.Result;
import com.fatmeraid.dao.UserDao;
import com.fatmeraid.service.UserCenterService;
import com.fatmeraid.service.UserService;
import com.fatmeraid.vo.user.ModifyPasswordVo;
import com.fatmeraid.vo.user.ModifyUserVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.UpdateProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.text.Style;

@Tag(name = "个人中心")
@RestController
@RequestMapping("/userCenter")
public class UserCenterController {

	@Autowired
	private UserCenterService userCenterService;

	@Operation(summary = "修改个人信息")
	@PutMapping("/updateUserInfo")
	public Result<Boolean> updateUserInfo(@RequestBody ModifyUserVo modifyUserVo) {
		 boolean result =userCenterService.updateUserInfo(modifyUserVo);
		 if (!result){
			 return Result.fail();
		 }
		 return Result.ok();
	}

	@Operation(summary = "修改密码")
	@PutMapping("/updatePassword")
	public Result<Boolean> updatePassword(@RequestBody ModifyPasswordVo modifyPasswordVo) {
		System.out.println(modifyPasswordVo);
		boolean result =userCenterService.updatePassword(modifyPasswordVo);
		if (!result){
			return Result.fail();
		}
		return Result.ok();
	}
}
